- if <%= config.model == "crecto" ? "changeset" : @name %>.errors
  ul.errors
    - <%= config.model == "crecto" ? "changeset" : @name %>.errors.each do |error|
      li = error.to_s

== form(action: "/<%= name_plural -%>/#{<%= @name -%>.id.to_s}", method: <%= @name %>.id ? :patch : :post) do
  == csrf_tag
<%- @fields.reject{|f| f.hidden }.each do |field| -%>
  .form-group
  <%- case field.type
     when "text" -%>
    == text_area(name: "<%= field.name -%>", content: <%= @name %>.<%= field.name %>, placeholder: "<%= field.name.capitalize %>", class: "form-control", size: "30x10")
  <%- when "boolean" -%>
      == label(<%=":#{field.name}"%>) do
        == check_box(<%=":#{field.name}, checked: #{@name}.#{field.name}.to_s == \"1\""%>)
  <%- when "reference" -%>
    == label(<%=":#{field.name}"%>)
    == select_field(name: "<%= field.name %>_id", collection: <% if config.model == "crecto" %>Repo.all(<%= field.class_name %>)<% else %><%= field.class_name %>.all<% end %>.map{|<%= field.name %>| [<%= field.name %>.id, <%= field.name %>.id]}, selected: <%= @name %>.<%= field.name %>_id, class: "form-control")
  <%- else -%>
    == text_field(name: "<%= field.name %>", value: <%= @name %>.<%= field.name %>, placeholder: "<%= field.name.capitalize %>", class: "form-control")
  <%- end -%>
<%- end -%>
  == submit("Submit", class: "btn btn-success btn-sm")
  == link_to("Back", "/<%= name_plural %>", class: "btn btn-light btn-sm")
